package com.gitee.wsl.collections.trie.api

import com.gitee.wsl.collections.map.api.IterableSortedMap
import com.gitee.wsl.collections.map.api.SortedMap


/**
 * Defines the interface for a prefix tree, an ordered tree data structure. For more information, see [Tries](https://en.wikipedia.org/wiki/Trie).
 *
 * @param <K> the type of the keys in this map
 * @param <V> the type of the values in this map
 * @since 4.0
</V></K> */
interface Trie<K, V> : IterableSortedMap<K, V> {
    /**
     * Returns a view of this [Trie] of all elements that are prefixed by the given key.
     *
     *
     * In a [Trie] with fixed size keys, this is essentially a [.get] operation.
     *
     *
     *
     * For example, if the [Trie] contains 'Anna', 'Anael', 'Analu', 'Andreas', 'Andrea', 'Andres', and 'Anatole', then a lookup of 'And' would return
     * 'Andreas', 'Andrea', and 'Andres'.
     *
     *
     * @param key the key used in the search
     * @return a [SortedMap] view of this [Trie] with all elements whose key is prefixed by the search key
     */
    fun prefixMap(key: K): SortedMap<K, V>
}